/**=============================================================================
@file
    qhdsp_hvx.h

@brief
    Header file of QHDSP_HVX library.

Copyright (c) 2020 Qualcomm Technologies Incorporated.
All Rights Reserved. Qualcomm Proprietary and Confidential.
=============================================================================**/

#ifndef _QHDSP_MY_HVX_H
#define _QHDSP_MY_HVX_H

#ifdef __cplusplus
#define restrict __restrict__
extern "C" {
#endif

#include <stdint.h>
#include "qhcomplex.h"
#include "qhl_types.h"

/**
 * @brief           [HVX] Real 1D 8x32 2^N fixed-point FFT
 * @param[in]       input - input samples (unsigned 8-bit)
 * @param[in]       N - number of points on which FFT is performed
 * @param[in]       w1 - twiddle factors - for N/2-point complex FFT
 * @param[in]       w2 - twiddle factors - for last stage
 * @param[out]      output - FFT output buffer (signed 32-bit complex)
 * @note
 *                  - Scale factor: 1/N
 *                  - input format Q7, output format Q<log2(N)>.<31-log2(N)>; example: N=128 -> log2(N)=7 -> output format Q7.24
 *                  - Assumptions:
 *                                  1. input, w1, w2, output - buffer aligned by 128bytes
 *                                  2. w1, w2 - generated with qhdsp_hvx_fft_gen_twiddles_real_ach() function
 *                                  3. N is power of 2 and N>=128
 */
//_yysh
int32_t qhdsp_hvx_acw_r1dfft_ah(const int16_t *input, uint32_t N, const int32_t *w1, const int32_t *w2, int64_t *output);
/**
 * @brief           [HVX] Real 2D (NxN) 8x32 2^N fixed-point FFT
 * @param[in]       input - input samples (unsigned 8-bit)
 * @param[in]       N - number of points (of both dimensions) on which FFT is performed
 * @param[in]       w1 - twiddle factors - for N/2-point complex FFT
 * @param[in]       w2 - twiddle factors - for last stage
 * @param[out]      output - FFT output buffer (signed 32-bit complex)
 * @note
 *                  - Scale factor: 1/N^2
 *                  - input format Q7, output format Q<2*log2(N)>.<31-2*log2(N)>; example: N=128 -> 2*log2(N)=7 -> output format Q14.17
 *                  - Assumptions:
 *                                  1. input, w1, w2, output - buffer aligned by 128bytes
 *                                  2. w1, w2 - generated with qhdsp_hvx_2D_fft_gen_twiddles_real_ach() function
 *                                  3. N is power of 2 and N>=128
 *                                  4. 2D FFT assumes width=height=stride -> N
 */
//_yysh
int32_t qhdsp_hvx_acw_r2dfft_ah(const int16_t *input, uint32_t N, const int32_t *w1, const int32_t *w2, int64_t *output);

/**
 * @brief           [HVX] Real 1D 32x8 2^N fixed-point IFFT
 * @param[in]       input - input values (signed 32-bit complex)
 * @param[in]       N - number of points on which IFFT is performed
 * @param[in]       w1 - twiddle factors - for N/2-point complex IFFT
 * @param[in]       w2 - twiddle factors - for last stage
 * @param[out]      output - IFFT output buffer (unsigned 8-bit)
 * @note
 *                  - input format Q<log2(N)>.<31-log2(N)>; example: N=128 -> log2(N)=7 -> input format Q7.24, output format Q7
 *                  - Assumptions:
 *                                  1. input, w1, w2, output - buffer aligned by 128bytes
 *                                  2. w1, w2 - generated with qhdsp_hvx_fft_gen_twiddles_real_ach() function
 *                                  3. N is power of 2 and N>=128
 */
//_yysh
int32_t qhdsp_hvx_ah_r1difft_acw(const int64_t *input, uint32_t N, const int32_t *w1, const int32_t *w2, int16_t *output);

/**
 * @brief           [HVX] Real 2D (NxN) 32x8 2^N fixed-point IFFT
 * @param[in]       input - input values (signed 32-bit complex)
 * @param[in]       N - number of points (of both dimensions) on which IFFT is performed
 * @param[in]       w1 - twiddle factors - for N/2-point complex IFFT
 * @param[in]       w2 - twiddle factors - for last stage
 * @param[out]      output - IFFT output buffer (unsigned 8-bit)
 * @note
 *                  - input format Q<2*log2(N)>.<31-2*log2(N)>; example: N=128 -> 2*log2(N)=7 -> input format Q14.17, output format Q7
 *                  - Assumptions:
 *                                  1. input, w1, w2, output - buffer aligned by 128bytes
 *                                  2. w1, w2 - generated with qhdsp_hvx_2D_fft_gen_twiddles_real_ach() function
 *                                  3. N is power of 2 and N>=128
 *                                  4. 2D IFFT assumes width=height=stride -> N
 */
//_yysh
int32_t qhdsp_hvx_ah_r2difft_acw(const int64_t *input, uint32_t N, const int32_t *w1, const int32_t *w2, int16_t *output);

/**
 * @brief           [HVX] Complex 1D 8x32 2^N fixed-point FFT
 * @param[in]       input - input samples (unsigned 8-bit complex)
 * @param[in]       N - number of points on which FFT is performed
 * @param[in]       w - twiddle factors
 * @param[out]      output - FFT output buffer (signed 32-bit complex)
 * @note
 *                  - Scale factor: 1/N
 *                  - input format Q7, output format Q<log2(N)>.<31-log2(N)>; example: N=128 -> log2(N)=7 -> output format Q7.24
 *                  - Assumptions:
 *                                  1. input, w, output - buffer aligned by 128bytes
 *                                  2. w - generated with qhdsp_hvx_fft_gen_twiddles_complex_ach() function
 *                                  3. N is power of 2 and N>=64
 */
//_yysh
int32_t qhdsp_hvx_acw_c1dfft_ach(const int32_t *input, uint32_t N, const int32_t *w, int64_t *output);

/**
 * @brief           [HVX] Complex 1D 32x8 2^N fixed-point IFFT
 * @param[in]       input - input values (signed 32-bit complex)
 * @param[in]       N - number of points on which IFFT is performed
 * @param[in]       w - twiddle factors
 * @param[out]      output - IFFT output buffer (unsigned 8-bit complex)
 * @note
 *                  - input format Q<log2(N)>.<31-log2(N)>; example: N=128 -> log2(N)=7 -> input format Q7.24, output format Q7
 *                  - Assumptions:
 *                                  1. input, w, output - buffer aligned by 128bytes
 *                                  2. w - generated with qhdsp_hvx_fft_gen_twiddles_complex_ach() function
 *                                  3. N is power of 2 and N>=64
 */
//_yysh
int32_t qhdsp_hvx_ach_c1difft_acw(const int64_t *input, uint32_t N, const int32_t *w, int32_t *output);


#ifdef __cplusplus
}
#endif

#endif /* _QHDSP_HVX_H */
